<template>
	<view>
		<u-loading-page :loading="loadding" loading-mode="semicircle" loading-text="加载中"></u-loading-page>
		<view class="policy_box" v-if="!loadding">
			<view class="policy_list">
				<view class="policy_title_tag">
					<text class="policy_title">条件</text>
				</view>
				<view class="info_item">
					交易类型
					<view class="">
						<view class="item-tag" v-for="(item,index) in data.tran" :key="index">
							<u-tag :text="item.name" plain size="mini"></u-tag>
						</view>
					</view>
				</view>
				<view class="info_item">
					卡类型
					<view class="">
						<view class="item-tag" v-for="(item,index) in data.card" :key="index">
							<u-tag :text="item.name" plain size="mini"></u-tag>
						</view>
					</view>
				</view>
				<view class="info_item">
					费率
					<view class="">
						<view class="item-tag" v-for="(item,index) in data.rate" :key="index">
							<u-tag :text="item.name" plain size="mini"></u-tag>
						</view>
					</view>
				</view>
				<view class="info_item">
					收款方式
					<view class="">
						<view class="item-tag" v-for="(item,index) in data.channel" :key="index">
							<u-tag :text="item.name" plain size="mini"></u-tag>
						</view>
					</view>
				</view>
			</view>
			<view v-if="data.policy_profit_num > 0" class="policy_list">
				<view class="policy_title_tag">
					<text class="policy_title">分润</text>
				</view>
				<view class="ha_setup_box">
					<view class="policy_list" v-for="(item,index) in data.policy_profit" :key="index"
						v-if="item.profit_base>0 || item.profit_hide>0">
						<view class="ha_setup_list profit_list">
							<text class="profit_tag">{{item.tran}}</text>
							<text class="profit_tag">{{item.rate}}</text>
							<text class="profit_tag">{{item.card}}</text>
							<text class="profit_tag">{{item.channel}}</text>
						</view>
						<view v-if="item.profit_base>0" class="info_item">
							<text>结算</text>
							<view class="">
								<text class="red-text">{{item.profit_base}}</text>
							</view>
						</view>
						<view v-if="item.profit_hide>0" class="info_item">
							<text>隐形</text>
							<view class="">
								<text class="red-text">{{item.profit_hide}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view v-if="data.policy_cash_num > 0" class="policy_list">
				<view class="policy_title_tag">
					<text class="policy_title">激活返现</text>
				</view>
				<view class="info_item">
					天数限制
					<view class="">
						<text class="red-text">{{data.policy_cash.day_limit}}</text>
						<text class="grey-text">天</text>
					</view>
				</view>
				<view class="info_item">
					刷卡金额
					<view class="">
						<text class="red-text">{{data.policy_cash.money}}</text>
						<text class="grey-text">元</text>
					</view>
				</view>
				<view v-if="data.policy_cash.base>0" class="info_item">
					基础金额
					<view class="">
						<text class="red-text">{{data.policy_cash.base}}</text>
						<text class="grey-text">元</text>
					</view>
				</view>
				<view v-if="data.policy_cash.hide>0" class="info_item">
					隐形金额
					<view class="">
						<text class="red-text">{{data.policy_cash.hide}}</text>
						<text class="grey-text">元</text>
					</view>
				</view>
			</view>
			<view v-if="data.deposit && data.deposit.reward" class="policy_list">
				<view class="policy_title_tag">
					<text class="policy_title">押金</text>
				</view>
				<view v-if="data.policy_simcard.base>0" class="info_item">
					金额
					<view class="">
						<text class="red-text">{{data.deposit.reward}}</text>
						<text class="grey-text">元</text>
					</view>
				</view>
			</view>
			<view v-if="data.deposit_reward && data.deposit_reward > 0" class="policy_list">
				<view class="policy_title_tag">
					<text class="policy_title">押金考核</text>
				</view>
				<view v-if="data.deposit_standard.length>0" class="deposit_standard">
					<view class="items">
						<view class="left">
							时间段(天)
						</view>
						<view class="right">
							刷卡金额
						</view>
					</view>
					<view v-for="(item,index) in data.deposit_standard" :key="index" class="item">
						<view class="left">
							{{item.day_start}} ~ {{item.day_end}}
						</view>
						<view class="right">
							{{item.require}}
						</view>
					</view>
				</view>
				<view v-if="data.policy_simcard.base>0" class="info_item">
					金额
					<view class="">
						<text class="red-text">{{data.deposit_reward}}</text>
						<text class="grey-text">元</text>
					</view>
				</view>
			</view>
			<view v-if="data.policy_simcard_num > 0" class="policy_list">
				<view class="policy_title_tag">
					<text class="policy_title">流量卡</text>
				</view>
				<view v-if="data.policy_simcard.base>0" class="info_item">
					基础金额
					<view class="">
						<text class="red-text">{{data.policy_simcard.base}}</text>
						<text class="grey-text">元</text>
					</view>
				</view>
				<view v-if="data.policy_simcard.hide>0" class="info_item">
					隐形金额
					<view class="">
						<text class="red-text">{{data.policy_simcard.hide}}</text>
						<text class="grey-text">元</text>
					</view>
				</view>
			</view>
			<view v-if="data.policy_standard_num > 0" class="policy_list" v-for="(item,index) in data.policy_standard"
				:key="index">
				<view class="policy_title_tag">
					<text class="policy_title">达标奖励</text>
				</view>
				<view class="info_item">
					交易天数
					<view class="">
						<text class="red-text">{{item.day_limit}}</text>
						<text class="grey-text">天</text>
					</view>
				</view>
				<view class="info_item">
					刷卡金额
					<view class="">
						<text class="red-text">{{item.money}}</text>
						<text class="grey-text">元</text>
					</view>
				</view>
				<view v-if="item.base > 0" class="info_item">
					基础金额
					<view class="">
						<text class="red-text">{{item.base}}</text>
						<text class="grey-text">元</text>
					</view>
				</view>
				<view v-if="item.hide > 0" class="info_item">
					隐形金额
					<view class="">
						<text class="red-text">{{item.hide}}</text>
						<text class="grey-text">元</text>
					</view>
				</view>
			</view>
		</view>
		<!-- <u-empty v-else mode="page" icon="/static/Empty/data_null.png"></u-empty> -->
	</view>
</template>

<script>
	import policy from '@/component/add_policy.vue'
	export default {
		data() {
			return {
				loadding: true,
				product_id: null,
				data: {},
				display: false,
				type: null,
				_url: ''
			}
		},
		components: {
			policy
		},
		onLoad(e) {
			this.product_id = e.id
			this.type = e.type
			if (this.type == 1) {
				this._request()
			} else if (this.type == 2) {
				this._requests()
			}
		},
		methods: {
			async _request() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp({
					url: 'Setting/getMyDefaultPolicy',
					data: {
						product_id: this.product_id
					},
					header: {
						'token': userinfo.token
					},
				});
				this.loadding = false
				if (res.code == 1) {
					this.data = res.data
					this.display = true
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none',
						duration: 3000
					})
				}
			},
			async _requests() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp({
					url: 'Setting/getPolicyDetail',
					data: {
						policy_id: this.product_id
					},
					header: {
						'token': userinfo.token
					},
				});
				this.loadding = false
				if (res.code == 1) {
					this.data = res.data
					this.display = true
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none',
						duration: 3000
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.info_item {
		margin-top: 20rpx;
		font-size: 28rpx;
		display: flex;
		justify-content: space-between;
		color: #666;

		.item-tag {
			margin-left: 6rpx;
		}

		text {
			display: flex;
		}

		view {
			// width: 50%;
			// text-align: right;
			display: flex;
			justify-content: flex-end;
			flex-wrap: wrap;

			.multiple {
				border: #eee 1px solid;
				padding: 10rpx;
				box-sizing: border-box;
				width: calc(100% - 12rpx);
				border-radius: 5rpx;
			}
		}
	}

	.confirm {
		padding: 20rpx;
		box-sizing: border-box;
		width: 80%;
		margin: 50rpx auto 0 auto;
		border-radius: 50rpx;
		background-color: #1688f1;
		color: #fff;
		text-align: center;
	}

	.policy_box {
		padding: 30rpx;
		box-sizing: border-box;

		.policy_list {
			padding: 20rpx;
			border-radius: 15rpx;
			box-shadow: 0px 1px 14px -10px #999;
			margin-bottom: 30rpx;


			.generate {
				display: flex;
				justify-content: center;
			}

			.policy_standard {
				margin-bottom: 30rpx;
			}

			.policy_standard:not(:first-child) {
				margin-top: 20rpx;
				padding-top: 20rpx;
				border-top: #bcbcbc 1px solid;
			}

			.policy_item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-bottom: 10rpx;

				text {
					font-size: 24rpx;
					color: #999;
				}
			}

			.policy_title_tag {
				display: block;
				padding: 0 0 20rpx 0;
				margin-bottom: 20rpx;
				border-bottom: #ebebeb dotted 1px;

				.policy_title {
					border-left: 8rpx solid #1792ff;
					padding: 0 0 0rpx 10rpx;
					line-height: 28rpx;
					width: 100%;
					display: block;
					font-size: 28rpx;
					color: #333;
					font-weight: bold;
					margin-bottom: 4rpx;
				}
			}
			
			.deposit_standard {
				padding: 0 20rpx 10rpx 0;
				font-size: 24rpx;
				border-bottom: 1px dotted #ebebeb;
				.items {
					padding-bottom: 20rpx;
					display: flex;
					justify-content: space-between;
				}
				.item {
					padding: 10rpx 0;
					border-top: 1px dotted #ebebeb;
					display: flex;
					justify-content: space-between;
				}
			}
		}
	}

	input {
		padding: 5px 0;
		border: 1px solid #eee;
		font-size: 13px;
		text-align: center;
		border-radius: 5rpx;
	}

	.ha_setup_box {

		.ha_setup {
			.ha_setup_list {
				margin-bottom: 20rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.average {
					display: block;
					text-align: center;
					font-size: 24rpx;
					flex: 1;
				}
			}

			.ha_setup_tit {
				border-bottom: #eee 1px solid;
				padding-bottom: 20rpx;
			}
		}
	}

	.red-text {
		color: red;
		font-weight: bold;
		padding-right: 10rpx;
	}

	.grey-text {
		color: #bcbcbc;
		font-size: 24rpx;
		line-height: 38rpx;
	}

	.profit_list {
		display: flex;
		font-size: 28rpx;
		padding-bottom: 16rpx;
		border-bottom: #ebebeb dotted 1px;
		justify-content: space-between;

		.profit_tag {
			display: flex;
			text-align: center;
			font-size: 28rpx;
			margin-right: 5%;
		}
	}
</style>